{include file='_header'}
<div class="page-header">
    当前位置：<span class="text-primary">{if !empty($item['id'])}编辑{else}添加{/if}操作员 <small>{if !empty($item['id'])}修改【{$item['username']}】{/if}</small></span>
</div>
<div class="page-content">
    <div class="page-sub-toolbar">
        <span class=''>
            <a class="btn btn-primary btn-sm" href="{:url('merch/perm/useradd')}">添加新操作员</a>
	    </span>
    </div>
    <form id="dataform" action="" method="post" class="form-horizontal form-validate" >
        <input type="hidden" name="id" value="{$item['id']}" />
 

                 <div class="form-group">

                     <label class="col-lg control-label must">操作员用户名</label>

                    <div class="col-sm-9 col-xs-12">
                        <input type="text" name="username" class="form-control" value="{$item['username']}" {if !empty($item)}readonly{/if} data-rule-required=true autocomplete="off" />
	                   <span class='help-block'>您可以直接输入系统已存在用户，且保证用户密码正确才能添加</span>
                    </div>

                </div>

                <div class="form-group">

                    <label class="col-lg control-label must">操作员密码</label>
                    <div class="col-sm-9 col-xs-12">
                        <input type="password" name="password" class="form-control" value="" autocomplete="off" {if empty($item['pwd'])}data-rule-required='true' {/if}/>
                    </div>
                </div>
                 <div class="form-group">

                    <label class="col-lg control-label">所属角色</label>

                    <div class="col-sm-9 col-xs-12">
                        <input type='hidden' id='userid' name='roleid' value="{$item['roleid']}" />

                        <div class='input-group'>

                            <input type="text" name="user" maxlength="30" value="{$item['rolename']}" id="user" class="form-control" readonly required/>

                            <div class='input-group-btn'>

                                <button class="btn btn-default" type="button" onclick="popwin = $('#modal-module-menus1').modal();">选择角色</button>

                                <button class="btn btn-danger" type="button" onclick="$('#userid').val('');$('#user').val('');">清除选择</button>

                            </div>

                        </div>

						<span class='help-block'>如果您选择了角色，则此用户本身就继承了此角色的所有权限</span>

                        <div id="modal-module-menus1"  class="modal fade" tabindex="-1">

                            <div class="modal-dialog" style='width: 920px;'>

                                <div class="modal-content">

                                    <div class="modal-header"><button aria-hidden="true" data-dismiss="modal" class="close" type="button">×</button><h3>选择角色</h3></div>

                                    <div class="modal-body" >

                                        <div class="row">

                                            <div class="input-group">

                                                <input type="text" class="form-control" name="keyword" value="" id="search-kwd1" placeholder="请输入角色名称" />

                                                <span class='input-group-btn'><button type="button" class="btn btn-default" onclick="search_users();">搜索</button></span>

                                            </div>

                                        </div>

                                        <div id="module-menus1" style="padding-top:5px;"></div>

                                    </div>

                                    <div class="modal-footer"><a href="#" class="btn btn-default" data-dismiss="modal" aria-hidden="true">关闭</a></div>

                                </div>

                            </div>

                        </div>
                    </div>

                </div>

                <div class="form-group">

                    <label class="col-lg control-label">状态</label>

                    <div class="col-sm-9 col-xs-12">
                        <label class='radio-inline'>

                            <input type='radio' name='status' value=1' {if $item['status']==1}checked{/if} /> 启用

                        </label>

                        <label class='radio-inline'>

                            <input type='radio' name='status' value=0' {if $item['status']==0}checked{/if} /> 禁用

                        </label>
                    </div>

                </div>

                 <div class="form-group">

                    <label class="col-lg control-label"></label>

                    <div class="col-sm-9 col-xs-12">
                            <input type="hidden" name="uid" value="{$item['uid']}" />

                        <input type="submit" value="提交" class="btn btn-primary" />
                       <input type="button" name="back" onclick='history.back()' style='margin-left:10px;' value="返回列表" class="btn btn-default" />

                    </div>

                </div>

 

    </form>

</div>

<script language='javascript'>
    function search_users() {
        $("#module-menus1").html("正在搜索....")
        $.get('{:url("merch/perm/rolequery")}', {
            keyword: $.trim($('#search-kwd1').val())
        }, function(dat){
            $('#module-menus1').html(dat);
        });
    }
    function select_role(o) {
        $("#userid").val(o.id);
        $("#user").val( o.rolename );
        $(".close").click();
    }
</script>
{include file='_footer'}

 

